<script setup>
import { ref } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const username = ref('')
const password = ref('')

const islogin = () => {
    if (username.value === 'admin' && password.value === '123456') {
        alert('登录成功')
        router.push('/home')
    } else {
        alert('账号或密码错误！')
    }
}
</script>

<template>
    <div class="login-box">
        <div class="login-header">
            <h2>用户登录</h2>
        </div>
        <div class="login-body">
            <div class="input-group">
                <label for="username">账号：</label>
                <input type="text" id="username" placeholder="请输入您的账号" class="input-field" v-model="username">
            </div>
            <div class="input-group">
                <label for="password">密码：</label>
                <input type="password" id="password" placeholder="请输入您的密码" class="input-field" v-model="password">
            </div>
        </div>
        <button class="login-button" @click="islogin">登 录</button>
    </div>
</template>

<style scoped>
* {
    margin: 0;
    padding: 0;
}

.login-box {
    width: 400px;
    margin: 100px auto;
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    padding-bottom: 30px;
}

.login-header {
    background-color: #a777e3;
    color: white;
    padding: 25px 0;
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.login-body {
    padding: 0 40px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
}

.input-field {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}


.login-button {
    display: block;
    width: 80%;
    margin: 25px auto 0;
    background-color: #a777e3;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}
</style>